(function() {
	if (typeof delicious == 'undefined') {
		delicious = {};
	}

	var src2 = 'http://badges.del.icio.us/feeds/json/url/data?url=';

	if ( delicious.url ) {
		src2 += delicious.url;
		myURL = delicious.url;
	} else {
		if ((location.href).indexOf('?') >= 0) {
			src2 += (location.href).substring(0, (location.href).indexOf('?'));
			myURL = (location.href).substring(0, (location.href).indexOf('?'));
		} else {
			src2 += location.href;
			myURL = location.href;
		}
	}

	src2 += "&amp;callback=displayURL";

	if ( delicious.title ) {
		myTitle = delicious.title;
	} else {
		myTitle =  document.title;
	} 

	var myText = '';

	if ( delicious.customText ) {
		myText = delicious.customText;
	} 

	if ( delicious.pageId ) {
		myId = 'delicious' + delicious.pageId;
	} else {
		myId =  'deliciousCount';
	} 

	var src = 'http://delicious.com/save?v=5&noui&jump=close&url=' + encodeURIComponent(myURL) + "&title=" + encodeURIComponent(myTitle);  ;
	var html = '';

	if (myText == ''){
		html += '<a href="http://delicious.com/url/view?url=' + myURL + '" target="_blank" title="View details on Delicious">'+'<div style="background:#999999;width:50px;height:45px;padding:1px 1px;"><center><span style= "font-family:Arial;text-decoration:none;font-weight:bold;font-size:18px;color:#FFFFFF;" id="' + myId +'">0</span><div style= "font-family:Arial;font-size:11px;color:#FFFFFF;">saves</div></center></div></a>';
		html += '<div style="background:#3333CC;width:50px;padding:1px 1px;"><center><a href="http://delicious.com/save" title="Save on Delicious" onclick="window.open(\'' + src + '\', \'delicious\',\'toolbar=no,width=550,height=550\'); return false;"><span style= "font-family:Arial;font-size:11px;color:#FFFFFF;">delicious</span></a></center></div>'
	} else {
	    html += '<a href="http://delicious.com/save" title="Save on Delicious" onclick="window.open(\'' + src + '\', \'delicious\',\'toolbar=no,width=550,height=550\'); return false;">' + myText +'</a>&nbsp;('
		html += '<span id="' + myId +'">0</span>&nbsp;saves)';
	}

//	html += '<script>function displayURL(data) { var urlinfo = data[0]; if (!urlinfo.total_posts) return; document.getElementById(\'' + myId+ '\').innerHTML = urlinfo.total_posts;}</script>'
//	html += '<script src = "' + src2 +'"></script>'; 
//	html += '<script type="text/javascript">var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");document.write(unescape("%3Cscript src=\'" + gaJsHost + "google-analytics.com/ga.js\' type=\'text/javascript\'%3E%3C/script%3E"));</script><script type="text/javascript">try {var pageTracker = _gat._getTracker("UA-12037055-1");pageTracker._trackPageview();} catch(err) {}</script>';
   	document.write(html);
	
})();